﻿@using MvcForum.Core.Constants
@using MvcForum.Web.Application.ExtensionMethods
@model MvcForum.Web.ViewModels.Admin.ListTagsViewModel

@{
    ViewBag.Title = "Manage Tags";
}

<div class="panel">
    <div class="panel-heading">
        <h5>@ViewBag.Title</h5>
    </div>
    <div class="panel-content">
        @using (Html.BeginForm("Manage", "AdminTag", FormMethod.Post))
        {
            @Html.HiddenFor(x => x.PageIndex)
            <div class="input-group tablesearch">
                @Html.TextBoxFor(x => Model.Search, new { @class = "form-control" })
                <span class="input-group-btn">
                    <button class="btn btn-default" type="submit">Search</button>
                </span>
            </div>
        }

        @if (Model.TotalCount > 0)
        {
            <table class="table table-bordered table-striped">
                <thead>
                    <tr>
                        <th style="width: 65px;">Edit</th>
                        <th>Tag</th>
                        <th style="width: 65px;">Delete</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var tag in Model.Tags)
                    {
                        <tr>
                            <td class="tagcell">
                                <span class="edittag">
                                    <a href="#" class="btn-mvc">
                                        <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                                    </a>
                                </span>
                                <span class="savetag" style="display:none;">
                                    <a href="#" class="btn-mvc">
                                        <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
                                    </a>
                                </span>
                            </td>
                            <td class="tagvalue">
                                <strong>

                                    <span class="tagvaluedisplay">
                                        @tag.Tag
                                    </span>
                                    <span class="tagvalueedit" style="display:none;">
                                        <input data-tagid="@tag.Id" data-oldvalue="@tag.Tag" type="text" id="@tag.Id" value="@tag.Tag" class="taginput form-control" />
                                    </span>

                                </strong>
                            </td>
                            <td>
                                <a href="@Url.Action("Delete", new { tag = tag.Tag, p = Model.PageIndex })" class="btn-mvc">
                                    <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
                                </a>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>

            if (Model.Tags.TotalPages > 1)
            {
                @Html.Pager(Convert.ToInt32(Model.PageIndex), ForumConfiguration.Instance.AdminListPageSize, Convert.ToInt32(Model.TotalCount), new { search = Model.Search })
            }
        }
    </div>
</div>



